#ifndef _DRV_MOTOR_H
#define _DRV_MOTOR_H

#include "stm32f10x.h"
#include "dev_motor.h"

#define PWM1_PORT	GPIOB
#define PWM1_PIN	GPIO_Pin_6
#define PWM2_PORT	GPIOB
#define PWM2_PIN	GPIO_Pin_7
#define PWM3_PORT	GPIOB
#define PWM3_PIN	GPIO_Pin_8
#define PWM4_PORT	GPIOB
#define PWM4_PIN	GPIO_Pin_9
	
#define MOTOR_TIME	TIM4
#define TIM4_PWM_FREQUENCE	1000 
#define TIM4_PWM_FRELOAD		100
#define TIM4_PWM_DIVISION		TIM_CKD_DIV1
#define TIM4_PWM_PRESCALER	(SystemCoreClock/(TIM_CKD_DIV1+1)/TIM4_PWM_FREQUENCE/TIM4_PWM_FRELOAD)



#define MOTOR_AIN1_PORT 		GPIOB
#define MOTOR_AIN1_PIN			GPIO_Pin_0
#define MOTOR_AIN2_PORT			GPIOA
#define MOTOR_AIN2_PIN			GPIO_Pin_7
	
#define MOTOR_BIN1_PORT 		GPIOB
#define MOTOR_BIN1_PIN			GPIO_Pin_1
#define MOTOR_BIN2_PORT 		GPIOB
#define MOTOR_BIN2_PIN			GPIO_Pin_2
	
#define MOTOR_CIN1_PORT 		GPIOB
#define MOTOR_CIN1_PIN			GPIO_Pin_3
#define MOTOR_CIN2_PORT 		GPIOA
#define MOTOR_CIN2_PIN			GPIO_Pin_15
	
#define MOTOR_DIN1_PORT 		GPIOB
#define MOTOR_DIN1_PIN			GPIO_Pin_4
#define MOTOR_DIN2_PORT 		GPIOB
#define MOTOR_DIN2_PIN			GPIO_Pin_5


void Drv_wirte_motor_duty(uint8_t id ,uint16_t duty);
void Drv_wirte_motor_dir(uint8_t id,uint8_t dir_state);
void Drv_Motor_Init(void);

#endif
